package org.thomias.multithread.synchronize;

import org.thomias.loggertest.YT;

public class Main {
	public static int b;
	public static int a;

	public static void main(String[] args) {
		YT.init();
		final Object o = new Object();
		a = 0;
		b = 0;
		new Thread(new Runnable() {

			@Override
			public void run() {
				while (true) {
					synchronized (o) {
						a = a + 1;
						b = b + 1;
					}					
				}
			}
		}).start();
		while (true) {
			
			synchronized (o) {
				YT.debug("a - b=" + (a - b));
				if (a != b) {
					YT.debug("EXIT");
					System.exit(0);
				}
			}			
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
